package com.kkb.hbase;


import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.ConnectionFactory;

import java.io.IOException;

/**
 * 连接Hbase 首先要知道zookeeper部署在哪里
 *
 * 1.初始化连接
 * 2.创建操作对象
 *      ddl操作：Admin
 *      dml操作：Table
 * 3.操作数据
 *      ddl操作
 *          建表 create 'myUser','f1','f2'
 *          删表 disable 'myUser'
 *               drop 'myUser'
 *          修改表 alter 'myUser',NAME=>'f1',VERSIONS=>3
 *      dml操作
 *          新增、修改 put 'myUser','rk001','f1:name','tom'
 *          删除 delete 'myUser','rk001','f1:name'
 *          查询
 *              get 'myUser','rk001','f1','f2:phone'
 *              scan 'myUser',{COLUMNS=>['f1','f2:phone']}
 *              过滤器查询
 *
 * 4.关闭
 */
public class hbaseOperation {

    public Connection connection;
    /**
     * 初始化连接
     */
    public void init() throws IOException {
        Configuration config = HBaseConfiguration.create();
        config.set("hbase.zookeeper.quorum","master:2181,slave1:2181,slave2:2181");
        connection = ConnectionFactory.createConnection(config);
    }
}
